package com.tuling.netty.nettyDemo;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class MyMessageEncoder extends MessageToByteEncoder<MyMessageProtol> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, MyMessageProtol myMessageProtol, ByteBuf byteBuf) throws Exception {
        byteBuf.writeInt(myMessageProtol.getLen());
        byteBuf.writeBytes(myMessageProtol.getContent());
    }
}
